﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OrderLibrary
{
    [Serializable]
    public class OrderDetails
    {
        private int orderid;
        public int OId
        {
            get
            {
                return orderid;
            }
            set
            {
                orderid = value;
            }
        }
        private string goodname;
        public string Goodname
        {
            get
            {
                return goodname;
            }
            set
            {
                goodname = value;
            }
        }
        private int goodnum;

        public int GoodNum
        {
            get
            {
                return goodnum;

            }
            set
            {
                goodnum = value;
            }
        }
        private double unitprice;//单价
        public double UnitPrice
        {
            get
            {
                return unitprice;
            }
            set
            {
                unitprice = value;
            }

        }
        public OrderDetails()
        {
            this.orderid = 0;
            this.goodname = string.Empty;
            this.goodnum = 0;
            this.unitprice = 0;
        }
        public OrderDetails(int oid, string Gname, int Gnum, double Unitprice)
        {
            this.orderid = oid;
            this.goodname = Gname;
            this.goodnum = Gnum;
            this.unitprice = Unitprice;
        }
        public double getGAmount()
        {
            double Amount = this.goodnum * this.unitprice;
            return Amount;
        }
        public int CompareTo(object o)
        {
            OrderDetails item = o as OrderDetails;
            return this.OId.CompareTo(item.OId);
        }
        public override bool Equals(object o)
        {
            OrderDetails item = o as OrderDetails;
            return this.OId == item.OId;
        }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override string ToString()
        {
            return $"订单编号：{OId}\t商品名：{Goodname}\t数量：{GoodNum}\t单价：{UnitPrice}";
        }




    }
}
